package cacao.server.normalize;

import java.util.Properties;

import cacao.server.CaCaOServer;

public class CaCaONormalizerFactory {
	private static CaCaONormalizer _normalizer=null;
	
	public static synchronized CaCaONormalizer getNormalizer(){
		if (_normalizer==null){
			Properties props = CaCaOServer.getInstance().getProperties();
			String className = props.getProperty("CaCaO.server.normalizer.class");
			if(className!=null){
				try{
					Class<?> theClass  = Class.forName(className);
					_normalizer = (CaCaONormalizer)theClass.newInstance();
				}
				catch(ClassNotFoundException e){
					//do nothing - handled afterwards
				}
				catch(IllegalAccessException e){
					//do nothing - handled afterwards
				}
				catch(InstantiationException e){
					//do nothing - handled afterwards
				}
				catch(ClassCastException e){
					//do nothing - handled afterwards
				}
			}
			if(_normalizer==null){
				_normalizer = new LowerCaseNormalizer();
			}
		}		
		return _normalizer;
	}
}
